<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <script src="__STATIC__/js/base.js"></script>
    <title>登录</title>
    <link rel="stylesheet" href="__STATIC__/css/base.css">
    <link rel="stylesheet" href="__STATIC__/css/login.css">
    <script src="__STATIC__/js/jquery-1.11.1.min.js"></script>
    <link rel="stylesheet" href="__STATIC__/js/layer_mobile/need/layer.css">
    <script src="__STATIC__/js/form_validation.js"></script>
    <script src="__STATIC__/js/layer_mobile/layer.js"></script>
</head>
<body>
<section class="wrap">
    <div id="login-form">
        <form    id="form1"   onsubmit="return searchSub() ">
            <div id="form-title">企业宝</div>
            <div class="form-content ">
                <div class="clearfix input-inline">
                    <div class="formtitle pull-left"><img src="__STATIC__/images/phone-img.png"></div>
                    <div class="formcontent pull-left">
                        <input tabindex="1" id="user_name" class="inputstyle1" autocomplete="off"  maxlength="15" type="text" name="username" placeholder="请输入注册手机号或用户名"/>
                    </div>
                </div>
            </div>
            <div class="form-content ">
                <div class="clearfix input-inline">
                    <div class="formtitle pull-left"><img src="__STATIC__/images/pwd-img.png"></div>
                    <div class="formcontent pull-left">
                        <input tabindex="2" id="pwd" oninput="if(!this.value){this.type='text'}else{this.type='password'}" class="inputstyle1"  autocomplete="off" maxlength="32"  type="text" name="loginPwd" placeholder="请输入6-32位由数字和字母组成的密码"/>
                    </div>
                </div>
            </div>
            <div class="login-orther clearfix">
                <div class="pull-left">没有账号？<a href="register.html" >立即注册</a></div>
                <div class="pull-right">忘记密码？<a href="/findpwd.html" >找回密码</a></div>
            </div>
            <input type="button" class="login-button"  value="登录" id="sublimit">
        </form>

    </div>
</section>
<script>
    $(function(){
        $('#sublimit').on('click',function(){
            var url = window.location.href;
            var  res = searchSub();
            if(res =='ok'){
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: url,
                    data:$('#form1').serialize(),// 你的formid
                    async: false,
                    error: function(request) {
                        layer.msg('登录失败', {
                            icon: 2,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                    },
                    success: function(data) {
                        if(data.code =='ok'){
                            var url=document.referrer;
                            var w=url.lastIndexOf('/');
                            var x=url.lastIndexOf(".");
                            if(url == null ||url == '' ){
                                window.location.href='/index.html'
                            }else {
                                if(url.substring(w+1,x)=="register"){
                                    window.location.href='/index.html'
                                }else {
                                    window.location.href=url;
                                }
                            }
                        }else {
                            if(data.type == 'password'){
                                $('#pwd').parents('.formline').children('.prompt').show();
                                $('#pwd').parents('.formline').children('.prompt').html(data.msg);
                            }else if(data.type == 'mobile') {
                                $('#user_name').parents('.formline').children('.prompt').show();
                                $('#user_name').parents('.formline').children('.prompt').html(data.msg);
                            }else {
                                $('.no').show();
                            }
                        }
                    }
                });
            }else{
                //信息框
                //提示
                layer.open({
                    content:res
                    ,skin: 'msg'
                    ,time:3 //2秒后自动关闭
                });
            }
        });
    });
</script>
</body>
</html>